<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>json数组</title>
</head>
<body>
    <script>
        //json数组
        //数组存放了若干个json对象
        let arr = [{"id":18,"name":"tom"},{"id":31,"name":"success"}];

        //遍历数组
        for(let i=0;i<arr.length;i++){
            console.log(arr[i]);
        }

        //直接遍历json对象
        let obj = {"id":18,"name":"tom","学历":"博士"};

        //获取json对象中所有的key和value
        for(let k in obj){//变量k实际上就是代表json对象obj中的key
            //json对象[key]得到json对象的value
            console.log(k+"->"+obj[k]);
        }

    </script>
</body>
</html>